bitkeeper revision 1.812 (405b0866daZJ0BPWPFHFWqcf9thiBA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 19 Mar 2004 14:49:10 +0000 (14:49 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 19 Mar 2004 14:49:10 +0000 (14:49 +0000)
utils.c:
  Autocreate /dev/xen/evtchn when starting xend, if it doesn't exist already.

tools/xend/lib/utils.c

index 24064b6a45d0e1278cd206be511882285f6e2936..07cba257f5540ac812436d01b5e2cb4fbdfde28c 100644 (file)
@@ -129,9 +129,15 @@ static PyObject *xu_notifier_new(PyObject *self, PyObject *args)
 
     xun = PyObject_New(xu_notifier_object, &xu_notifier_type);
 
+ reopen:
     xun->evtchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
     if ( xun->evtchn_fd == -1 )
     {
+        if ( (errno == ENOENT) &&
+             ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
+             (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600, 
+                    (EVTCHN_DEV_MAJOR << 8) | EVTCHN_DEV_MINOR) == 0) )
+            goto reopen;
         PyObject_Del((PyObject *)xun);
         return PyErr_SetFromErrno(PyExc_IOError);
     }